package com.study.compose.beta.activity

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import com.module.compose.base.BaseActivity
import com.module.compose.base.composable.CommonPage
import com.study.compose.beta.view.*

/**
 * 各种控件演示示例的容器，根据标题区分显示的内容
 */
class SampleActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val title = intent.getStringExtra("title") ?: "文字"
        setContent {
            Greeting(title)
        }
    }
}


@Composable
private fun Greeting(title: String) {
    CommonPage(title = title) {
        when (title) {
            "文字" -> TextSample()
            "按钮" -> ButtonSample()
            "状态管理" -> StateSample()
            "Visibility" -> VisibilitySample()
            "布局" -> LayoutSample()
            "列表" -> ListSample()
            "Grid" -> GridSample()
            "Pager" -> PagerSample()
            "LazyColumn" -> LazyColumnSample()
            "LazyRow" -> LazyRowSample()
            "输入框" -> TextFieldSample()
            "Image" -> ImageSample()
            "Canvas" -> CanvasSample()
            "SwipeToRefresh" -> SwipeToRefreshSample()
            "参考" -> ReferenceSample()
        }
    }
}